//
//  QNGridItem.h
//  TestZaker
//
//  Created by gang.xu on 13-4-25.
//  Copyright (c) 2013年 去哪儿. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum{
    QNGridItemModeNormal = 0,
    QNGridItemModeEditing = 1,
} QNMode;

@protocol QNGridItemDelegate;

@interface QNGridItem : UIView {
    UIButton *_mainButton;
    UIButton *_deleteButton;
    CGPoint _point; // long press point
    
    NSString *_title;
    UIImage *_icon;
    UIImage *_bgImage; // if nil will be blue color
    BOOL _isEditing;
    id <QNGridItemDelegate> _delegate;
}
@property (nonatomic, assign) BOOL isRemovable; // default NO
+ (id)allocWithFrame:(CGRect)frame delegate:(id<QNGridItemDelegate>)delegate title:(NSString *)title bgImage:(UIImage *)bgImage;
- (id)initWithFrame:(CGRect)frame delegate:(id<QNGridItemDelegate>)delegate title:(NSString *)title bgImage:(UIImage *)bgImage;
- (void)enableEditing;
- (void)disableEditing;
@end

@protocol QNGridItemDelegate <NSObject>
@optional
// 点击主按钮事件
- (void)gridItemDidClicked:(QNGridItem *)gridItem;
// 点击删除按钮事件
- (void)gridItemDidDeleted:(QNGridItem *)gridItem atTag:(NSInteger)tag;
@required
// 进入编辑模式
- (void)gridItemDidEnterEditingMode:(QNGridItem *)gridItem;
// 开始移动
- (void)gridItemDidMoved:(QNGridItem *)gridItem withLocation:(CGPoint)point moveGestureRecognizer:(UILongPressGestureRecognizer*)recognizer;
// 停止移动
- (void)gridItemDidEndMoved:(QNGridItem *)gridItem withLocation:(CGPoint)point moveGestureRecognizer:(UILongPressGestureRecognizer*)recognizer;
@end

